import Immutable from 'immutable';

import { ADD_SYSTEM_REDUX } from './actionTypes';
import preloadedState from '../../preloadedState';

const defaultSystem = preloadedState.get('system');

function reducer (state = defaultSystem, action) {
    const { type, payload:config } = action;
    let newState;

    switch (type) {
        case ADD_SYSTEM_REDUX:
            newState = Immutable.fromJS(config);
            newState = state.merge(newState);
            return newState;
        default:
            return state;
    }
}

export default reducer;